<script src="/javascripts/util.js" type="text/javascript"></script>
<script src="/javascripts/calendar.js" type="text/javascript"></script>
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
function checkNum(flag, msg_id, obj_name, msg_text)
{
    if (flag) {
        if ($(obj_name).value == "" || ! digCheck($(obj_name).value))
        {
            $(msg_id).innerText = msg_text;
            $(msg_id).style.display = "block";
            return false;
        }
        else return true;
    }
    else {
        $(msg_id).style.display = "none";
    }
}

function checkYM(flag, msg_id, obj_name, msg_text)
{
    if (flag) {
        if ($(obj_name).value == "" || ! checkYearMonth($(obj_name).value))
        {
            $(msg_id).innerText = msg_text;
            $(msg_id).style.display = "block";
            return false;
        }
        else return true;
    }
    else {
        $(msg_id).style.display = "none";
    }
}

function checkDate()
{
    if (checkYM(true,'id_get_date_at','get_date_at','月份输入错误'))
        frmSalePaper.submit();
}


</script>

<h1>报表中心 - <span id="secondHeading">查询对账单</span></h1>


<% if @flash[:notice] -%>
<div id="notice"><%= @flash[:notice] %></div>
<% end -%>

<form id="input-form" name="frmSalePaper" action="/query/reconciliation" method="post">
<table id="INPUT_TABLE">
<tr>
<TD width="20%">客户：</TD>
<TD><select name="agent_id">
<%@agents_1.each do |agent|%>
<option value="<%=agent.id%>"><%=agent.name%></option>
<%end%>
</select>
</TD>
</tr>
<tr>
<td>查询月份 ：</td>
<td> <input type="text" name="get_date_at" id="get_date_at" maxlength="20" onfocus ="checkYM(false,'id_get_date_at')" onblur="checkYM(true,'id_get_date_at',this.id,'月份输入错误')"/>   2007-06 <div class="redNsg" id="id_get_date_at" style="display:none;"></div>
</td>
</tr>
<tr>
<td colspan="2" align="right">　
<input  type="button" value="查询" class="sub" onclick="checkDate()">
</td>
</tr>
</table>
</form>
<%if @sale_papers%>

<STYLE type=text/css>
#compay_info{
    display: none;
}
</STYLE>


<div id="test">

<table id="compay_info" cellpadding="0" cellspacing="0" border="0">
<tr style="font-size:20px;font-weight:bold;">
<td align="center"><%= @company_info[0].value%></td>
</tr>

<tr style="font-size:20px;font-weight:bold;">
<td align="center">对 账 单</td>
</tr>

<tr style="font-size:12px;">
<td align="center">工厂地址：<%= @company_info[1].value%></td>
</tr>

<tr style="font-size:12px;">
<td align="center">电话：<%= @company_info[2].value %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;传真：<%= @company_info[3].value %></td>
</tr>

<tr style="font-size:12px;">
<td align="center">广东办事处地址：<%= @company_info[5].value %></td>
</tr>

<tr style="font-size:12px;">
<td align="center">电话：<%= @company_info[6].value %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;传真：<%= @company_info[7].value %></td>
</tr>


</table>

<table border="0" id="LIST_TB">
<tr id="LIST_TB_CONTENT1">
<td colspan="2">&nbsp;&nbsp;&nbsp;客户：<%= @agents ? @agents.name : '' %></td>
<td align="center" colspan="2"><%=params[:get_date_at]%></td>
<td align="right" colspan="2">货币：人民币&nbsp;&nbsp;&nbsp;</td>
</tr>
<TR id="LIST_TB_TITLE">
<td align="center" nowrap>送货日期</td>
<td align="center" nowrap>送货单号</td>
<td align="center" nowrap>品名规格</td>
<td align="center" nowrap>数量（K）</td>
<td align="center">单价（元/K）</td>
<td align="center">金额（元）</td>
</tr>
<% total=0.00 %>
<%@sale_papers.each do |item|%>
<TR id="LIST_TB_CONTENT1">
<!--
<td><%=item.id%></td>
<td><%=item.status%></td>
-->
<td><%=item.get_date_at%></td>
<td><%=item.serialno%></td>
<td><%=item.serial%></td>
<td><%= sprintf("%#.2f",item.current_count)%></td>
<td><%=item.price%></td>
<td align="center"><%= item.status.to_i==0 ? sprintf("%#.2f",item.current_count.to_f * item.price.to_f) : '-0.00' %></td>
<% total += item.status.to_i==0 ? item.current_count.to_f * item.price.to_f : 0 %>
</tr>
<%end%>
<tr id="LIST_TB_CONTENT1">
<td align="center">总 计</td>
<td align="left" colspan="4">大写:<script>document.write(DX(<%=sprintf("%#.2f",total)%>))</script></td>
<td align="center"><%=sprintf("%#.2f",total)%></td>
        </tr>
        <tr id="LIST_TB_CONTENT1">
                <td align="left" colspan="6"> 注：收到后请在三日内确认并签回，如无签回，则视为贵公司确认，请配合，谢谢！ </td>
        </tr>
        <tr id="LIST_TB_CONTENT1">
                <td align="left" colspan="4">客户回签：</td>
                <td align="right">制表：</td>
                <td align="left"><%=@session[:account].employee.name%></td>
        </tr>
        <tr id="LIST_TB_CONTENT1">
                <td align="left" colspan="6">（盖章）</td>
        </tr>
    </table>

</div>
    <table>
        <tr>
            <td>
                <input type="button" value="打印当前页" class="sub" onclick="openPrintWindow_special('test')"/>
                <input type="button" value="导出当前数据" class="sub" onclick="CellAreaExcel('LIST_TB')"/>
            </td>
        </tr>
    </table>
    <%end%>
